<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
</head>
<body>
    <!-- component 一个用于渲染动态组件或元素的“元组件” -->
    <div id="app">
        <button @click=" flag=!flag ">dianji</button>
        <component :is="flag?'a':'i'  ">123</component>
        <component :is="flag?'home':'iwork'"></component>
    </div>
</body>
<template id="home">
    <div>
        home....
    </div>
</template>
<template id="work">
    <div>
        work....
    </div>
</template>
</html>
<script>
    const app = Vue.createApp({
        data() {
            return {
                flag:false
            }
        },
        components:{
            home:{
                template:'#home'
            },
            iwork:{
                template:'#work'
            },
        }
    }).mount('#app')
</script>